package com.util;

import com.chen.R;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.GridView;
import android.widget.ImageView;

public class ImageAdapter extends BaseAdapter {
	private Context context;
	private int[] images = {R.drawable.psu1,R.drawable.psu2,
							R.drawable.psu3,R.drawable.psu13,
							R.drawable.psu4,R.drawable.psu14,
							R.drawable.psu5,R.drawable.psu15,
							R.drawable.psu6,R.drawable.psu1,
							R.drawable.psu7,R.drawable.psu2,
							R.drawable.psu8,R.drawable.psu3,
							R.drawable.psu9,R.drawable.psu4,
							R.drawable.psu10,R.drawable.psu5,
							R.drawable.psu11,R.drawable.psu6,
							R.drawable.psu12,R.drawable.psu7,};

	public ImageAdapter (Context context){
		this.context = context;
	}

	@Override
	public int getCount() {
		return images.length;
	}

	@Override
	public Object getItem(int position) {
		return null;
	}

	@Override
	public long getItemId(int position) {
		return 0;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		ImageView imageView;
		if(convertView == null){
			imageView = new ImageView(context);
			imageView.setLayoutParams(new GridView.LayoutParams(85, 85));
			imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
			imageView.setPadding(8, 8, 8, 8);
		} else {
			imageView = (ImageView) convertView;
		}
		imageView.setImageResource(images[position]);
		
		return imageView;
	}
}
